package com.example.shushiyunsst.fragment.main.home.child.miner.sub

import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.RecyclerView
import com.example.library_common.adapter.JssBaseViewHolder
import com.example.library_common.album.utils.Utils
import com.example.library_common.base.SimpleListFragment
import com.example.library_common.bean.CommonBean
import com.example.library_common.utils.PixUtils
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.home.child.miner.bean.PlantResultsBean
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration
import ikidou.reflect.TypeBuilder
import java.lang.reflect.Type

/**
 * 栽种成就
 * */
class PlantResultsFragment : SimpleListFragment<PlantResultsBean>() {

    companion object {
        fun newInstance(): PlantResultsFragment {
            val args = Bundle()

            val fragment = PlantResultsFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        isEnableLoadMore = false
        isAddDividerItemDecoration = false
    }

    override fun initView(view: View) {
        super.initView(view)
        view.setBackgroundResource(R.color.nav_bar_bg_color)
        mHeader.removeAllViews()
        addHeader(R.layout.plant_results_header_fragment)
        val mToolbar: Toolbar = mHeader.findViewById(R.id.mToolbar)
        mToolbar.setTitle(R.string.plant_results)
        mToolbar.setNavigationOnClickListener { onBackPressedSupport() }

    }





    override fun getItemLayout() = R.layout.plant_results_fragment

    override fun convertItem(helper: JssBaseViewHolder?, item: PlantResultsBean?) {
        helper?.setViewVisible(R.id.mask, helper.layoutPosition % 2 == 0)
    }

    override fun getListType(): Type {
        return TypeBuilder.newInstance(CommonBean::class.java)
            .beginSubType(List::class.java)
            .addTypeParam(PlantResultsBean::class.java).endSubType().build()
    }

    override fun netRequest() {
        val jsonFromRaw = Utils.getJsonFromRaw(_mActivity, R.raw.temp_fack_data)
        parseDate(jsonFromRaw)
    }
}